package graphics.app;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JFileChooser;
import javax.swing.JFrame;

public class GraphicsFiles {

	public static void save(JFrame frame,GraphicsData data){
		
		JFileChooser chooser=new JFileChooser();
		
		int result=chooser.showSaveDialog(frame);
		
		if(result==JFileChooser.APPROVE_OPTION){
			File f=chooser.getSelectedFile();
			
			try {
				BufferedWriter writer=new BufferedWriter(new FileWriter(f));
				for (int i = 0; i < data.getFormeCount(); i++) {
					writer.write(data.getForma(i).writeAsString()+"\n");
				}
				writer.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void open(JFrame frame,GraphicsData data){
		throw new RuntimeException("GraphicsFile.open has not been implemented");
		//TODO : to be implemented
	}
}
